<html>
<head><meta charset="utf-8"><title>Git Rebase Help · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Git.20Rebase.20Help.html">Git Rebase Help</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="177434797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Git%20Rebase%20Help/near/177434797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> luigishat <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Git.20Rebase.20Help.html#177434797">(Oct 05 2019 at 22:56)</a>:</h4>
<p>I'm Currently working on this PR (<a href="https://github.com/rust-lang/rust/pull/63906" target="_blank" title="https://github.com/rust-lang/rust/pull/63906">https://github.com/rust-lang/rust/pull/63906</a>) and I'm having trouble doing as "Bjorn3" says. Can somebody tell me how to git rebase my previous commits so I can push my new commit which I ran ./x.py test /src/doc/rust-ui --bless ?</p>



<a name="177435187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Git%20Rebase%20Help/near/177435187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Git.20Rebase.20Help.html#177435187">(Oct 05 2019 at 23:10)</a>:</h4>
<p>Let me try and understand what you're trying to do. You've got a new commit with the changes from <code>./x.py test src/doc/rustdoc-ui --bless</code> and you want to rebase your commits atop master?</p>



<a name="177435236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Git%20Rebase%20Help/near/177435236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Git.20Rebase.20Help.html#177435236">(Oct 05 2019 at 23:12)</a>:</h4>
<p><span class="user-mention" data-user-id="236486">@luigishat</span></p>



<a name="177442466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Git%20Rebase%20Help/near/177442466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> luigishat <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Git.20Rebase.20Help.html#177442466">(Oct 06 2019 at 03:26)</a>:</h4>
<p>The first part is right. What I'm trying to do is push these changes after ./x.py ... but git says there are none. So I was told to "rebase" all my previous commits and push my latest too see if that would work.</p>



<a name="177442471"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Git%20Rebase%20Help/near/177442471" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> luigishat <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Git.20Rebase.20Help.html#177442471">(Oct 06 2019 at 03:27)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span></p>



<a name="177450996"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Git%20Rebase%20Help/near/177450996" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Git.20Rebase.20Help.html#177450996">(Oct 06 2019 at 08:17)</a>:</h4>
<p><span class="user-mention" data-user-id="236486">@luigishat</span> can you print the output of <code>git status</code> and <code>git log</code> (perhaps only for the last handful of commits, in a gist or pastebin).</p>



<a name="177491703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Git%20Rebase%20Help/near/177491703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> luigishat <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Git.20Rebase.20Help.html#177491703">(Oct 07 2019 at 05:24)</a>:</h4>
<p>The git log is quite small so here is the paste</p>
<div class="codehilite"><pre><span></span>~/D/R/rust [cmp_fix] » git log                                          22:19:29
commit 4b57287baea7d0d79c3645f0cd22f7a0bbe6da09 (HEAD -&gt; cmp_fix, origin/cmp_fix)
Author: Caleb Behunin &lt;calebrobot88@gmail.com&gt;
Date:   Sun Sep 8 22:17:10 2019 -0700

    Reset Branch and Made Changes

commit d760df5aea483aae041c9a241e7acacf48f75035 (origin/master, origin/HEAD, master)
Merge: 783469ca09 53f4734794
Author: bors &lt;bors@rust-lang.org&gt;
Date:   Sun Aug 25 08:06:06 2019 +0000

    Auto merge of #63874 - spastorino:places-drive-by-cleanups, r=Centril

    Places drive by cleanups

    Small fixes of things meanwhile I was doing the box part of Place 2.0, based on @centril reviews.

commit 783469ca09005d135c3204a55069707d1cd705a9
Merge: 9267119019 5a7e1cb46a
Author: bors &lt;bors@rust-lang.org&gt;
Date:   Sun Aug 25 04:26:26 2019 +0000
:
</pre></div>



<a name="177491713"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Git%20Rebase%20Help/near/177491713" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> luigishat <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Git.20Rebase.20Help.html#177491713">(Oct 07 2019 at 05:25)</a>:</h4>
<p>and git status</p>
<div class="codehilite"><pre><span></span>~/D/R/rust [cmp_fix] » git status                                       22:24:21
On branch cmp_fix
Your branch is up to date with &#39;origin/cmp_fix&#39;.

nothing to commit, working tree clean
</pre></div>


<p><span class="user-mention" data-user-id="116107">@davidtwco</span></p>



<a name="177499841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Git%20Rebase%20Help/near/177499841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Git.20Rebase.20Help.html#177499841">(Oct 07 2019 at 08:31)</a>:</h4>
<p>So, the commit hash you have there, <code>4b57287baea7d0d79c3645f0cd22f7a0bbe6da09</code>, matches what is the latest on your PR, so I think Git is correct in thinking there's nothing new to push.</p>



<a name="177500045"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Git%20Rebase%20Help/near/177500045" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Git.20Rebase.20Help.html#177500045">(Oct 07 2019 at 08:34)</a>:</h4>
<p>I think the issue is that when your PR is tested by the CI, then it gets merged with master first, and when that happens, there are new/changed rustdoc tests that your changes will affect. Because your local branch isn't based on the most recent master, you don't have the new/changed rustdoc tests and so telling x.py to update the output <code>./x.py test src/doc/rustdoc-ui --bless</code> doesn't do anything! Here's what you want to do:</p>
<div class="codehilite"><pre><span></span>git checkout master
git pull upstream master
git checkout cmp_fix
git rebase master
./x.py test src/doc/rustdoc-ui --bless
</pre></div>


<p>Then commit and push as normal. If you don't have a remote named upstream, and the second command fails, then do <code>git remote add upstream https://github.com/rust-lang/rust.git</code>.</p>



<a name="177500051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Git%20Rebase%20Help/near/177500051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Git.20Rebase.20Help.html#177500051">(Oct 07 2019 at 08:34)</a>:</h4>
<p><span class="user-mention" data-user-id="236486">@luigishat</span></p>



<a name="177515231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Git%20Rebase%20Help/near/177515231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Paul Faria <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Git.20Rebase.20Help.html#177515231">(Oct 07 2019 at 12:45)</a>:</h4>
<p>This could also go faster with just <code>git checkout cmp_fix &amp;&amp; git rebase upstream/master</code>. Depends on if you want a local copy of <code>rust-lang</code>'s <code>master</code> branch or not</p>



<a name="177579233"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Git%20Rebase%20Help/near/177579233" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> luigishat <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Git.20Rebase.20Help.html#177579233">(Oct 08 2019 at 02:33)</a>:</h4>
<p><span class="user-mention" data-user-id="116107">@davidtwco</span>  Ok so I set my branch too master using "git checkout master" but when I try to "git pull upstream master" I get</p>
<div class="codehilite"><pre><span></span>remote: Not Found
fatal: repository &#39;https://github.com/rust-lang/rust/issues/63551/&#39; not found
</pre></div>


<p>Any thoughts ? ( I apologize I'm still very new too git's more advanced functionality)</p>



<a name="177579372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Git%20Rebase%20Help/near/177579372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> luigishat <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Git.20Rebase.20Help.html#177579372">(Oct 08 2019 at 02:37)</a>:</h4>
<p>Would I do something like "git remote set-url origin <a href="https://github.com/rust-lang/rust/issues/63906/" target="_blank" title="https://github.com/rust-lang/rust/issues/63906/">https://github.com/rust-lang/rust/issues/63906/</a>" ?</p>



<a name="177589001"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Git%20Rebase%20Help/near/177589001" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Git.20Rebase.20Help.html#177589001">(Oct 08 2019 at 07:04)</a>:</h4>
<p><span class="user-mention" data-user-id="236486">@luigishat</span> your remote url should be the url to the upstream repository, not the issue. Try:</p>
<div class="codehilite"><pre><span></span>git remote remove upstream
git remote add upstream https://github.com/rust-lang/rust.git
</pre></div>



<a name="177677986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Git%20Rebase%20Help/near/177677986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> luigishat <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Git.20Rebase.20Help.html#177677986">(Oct 09 2019 at 02:53)</a>:</h4>
<p>Ok running " ./x.py test src/doc/rustdoc-ui --bless". Thanks for helping me out <span class="user-mention" data-user-id="116107">@davidtwco</span></p>



<a name="177678633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Git%20Rebase%20Help/near/177678633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> luigishat <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Git.20Rebase.20Help.html#177678633">(Oct 09 2019 at 03:10)</a>:</h4>
<p>Also what does this line do "git rebase master" I can't seem to get my head wrapped around rebase in general. Does it squish all of the previous commits and put mine first ?</p>



<a name="177681437"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Git%20Rebase%20Help/near/177681437" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> luigishat <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Git.20Rebase.20Help.html#177681437">(Oct 09 2019 at 04:18)</a>:</h4>
<p>Any need to worry about these ? <span class="user-mention" data-user-id="116107">@davidtwco</span>  This occurs after running git rebase master</p>
<div class="codehilite"><pre><span></span>~/D/R/rust [cmp_fix] » git rebase upstream/master                       21:15:57
Current branch cmp_fix is up to date.
Auto packing the repository in background for optimum performance.
See &quot;git help gc&quot; for manual housekeeping.
warning: The last gc run reported the following. Please correct the root cause
and remove .git/gc.log.
Automatic cleanup will not be performed until the file is removed.

warning: There are too many unreachable loose objects; run &#39;git prune&#39; to remove them.
</pre></div>



<a name="177686811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Git%20Rebase%20Help/near/177686811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Git.20Rebase.20Help.html#177686811">(Oct 09 2019 at 06:44)</a>:</h4>
<p>Nah, don't worry. <code>git gc</code> just does a bit of house cleaning. It's complaining that you have a bunch of "old" commits that are no longer accessible</p>



<a name="177686838"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Git%20Rebase%20Help/near/177686838" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Git.20Rebase.20Help.html#177686838">(Oct 09 2019 at 06:45)</a>:</h4>
<p><code>git rebase upstream/master</code> basically takes what's in <code>upstream/master</code>, then applies each of your commit on top of that. It's nice because you get a linear history when you finally merge the branch.</p>



<a name="177686921"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Git%20Rebase%20Help/near/177686921" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Git.20Rebase.20Help.html#177686921">(Oct 09 2019 at 06:46)</a>:</h4>
<p>It can also edit the history (change commit contents or message, reorder them, squash multiple commits into a single one), but that's usually done as an "interactive rebase", <code>git rebase -i</code></p>



<a name="177687026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Git%20Rebase%20Help/near/177687026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Git.20Rebase.20Help.html#177687026">(Oct 09 2019 at 06:49)</a>:</h4>
<p>So if you notice a mistake in one of previous your commits, you can just <code>git commit -am "fix stuff"</code>, then <code>git rebase -i HEAD~5</code> and you'll get a list of the last five commits. In there you can move your "fix stuff" commit earlier, then mark it as "fixup" or "squash", meaning it will be combined with the previous one.</p>



<a name="177687129"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Git%20Rebase%20Help/near/177687129" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Git.20Rebase.20Help.html#177687129">(Oct 09 2019 at 06:51)</a>:</h4>
<p>It's usually fine to change history like that on a feature branch like your PR, but it's considered bad practice to do it on <code>master</code>, and some people might complain. And it's somewhat dangerous, in that if you misuse <code>git rebase</code> you can lose your work (you're not going to lose them, see <code>git reflog</code>, but that's a story for another day).</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>